home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 37
/
Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso
/
Aminet
/
dev
/
misc
/
gdbm.lha
/
gdbm-1.7.3
/
samp1.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1999-12-12
|
921b
|
37 lines
// small c++ to open store then close a gdbm file
// by Mike MacFaden 4/93 mike@premisys.com
// tested with gdbm 1.5 and gnu v2.2 c++ compiler
#include "iostream.h"
#include "gdbm.h"
extern int errno; /* C runtime library */
int main(int argc, char *argv[])
{
cout << "Sample C++ program create a gdbm file ./tgdbm " << endl;
GDBM_FILE pfile = gdbm_open("tstgdbm", 512, GDBM_WRCREAT, 00664, 0);
if (!pfile)
{
cout << "main:gdbm_open " << gdbm_errno << errno << endl;
return -1;
}
datum key = {"foo", strlen("foo")+1};
datum val = {"bar", strlen("bar")+1};
cout << "key is : " << key.dptr << endl;
cout << "data is : " << val.dptr << endl;
if (gdbm_store(pfile, key, val, GDBM_INSERT) != 0)
{
cout << "main:gdbm_store " << gdbm_errno << errno << endl;
return -1;
}
gdbm_close(pfile);
cout << "Sample C++ program complete" << endl;
return 0;
}